//-----------------------------------------------------------------------
// <copyright file="DeliveredOrderService.cs" company="Pyramid Consulting">
//     Copyright (c) Pyramid Consulting. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using MyFramework;
using MIMS.WRS.Entities;
using MIMS.WRS.Data;
    
namespace MIMS.WRS.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class DeliveredOrderService
    {
        #region DeliveredOrder

        public static void CreateDeliveredOrder(DeliveredOrder deliveredOrder)
        {            
            try
            {
                DeliveredOrderDAO deliveredOrderDAO = new DeliveredOrderDAO();
                deliveredOrderDAO.CreateDeliveredOrder(deliveredOrder);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessCreateDeliveredOrderException, ex);
            }
        }        

        public static void UpdateDeliveredOrder(DeliveredOrder deliveredOrder)
        {            
            try
            {
                DeliveredOrderDAO deliveredOrderDAO = new DeliveredOrderDAO();
                deliveredOrderDAO.UpdateDeliveredOrder(deliveredOrder);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessUpdateDeliveredOrderException, ex);
            }
        }        

        public static void DeleteDeliveredOrder(int deliveredOrderID)
        {            
            try
            {
                DeliveredOrderDAO deliveredOrderDAO = new DeliveredOrderDAO();
                deliveredOrderDAO.DeleteDeliveredOrder(deliveredOrderID);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessDeleteDeliveredOrderException, ex);
            }
        }
        
        public static DeliveredOrder GetDeliveredOrder(int deliveredOrderID)
        {            
            try
            {
                DeliveredOrderDAO deliveredOrderDAO = new DeliveredOrderDAO();
                return deliveredOrderDAO.GetDeliveredOrder(deliveredOrderID);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetDeliveredOrderException, ex);
            }
        }                

        public static DeliveredOrderCollection GetDeliveredOrders(DeliveredOrderColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                DeliveredOrderDAO deliveredOrderDAO = new DeliveredOrderDAO();
                return deliveredOrderDAO.GetDeliveredOrders(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetDeliveredOrdersException, ex);
            }
        }        

        public static DeliveredOrderCollection GetDeliveredOrders(DeliveredOrderColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                DeliveredOrderDAO deliveredOrderDAO = new DeliveredOrderDAO();
                return deliveredOrderDAO.GetDeliveredOrders(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetDeliveredOrdersException, ex);
            }
        }        

        #endregion

		public static DeliveredOrderCollection GetDeliveredOrders(string productCode, string supplierCode, int owner)
		{            
			try
			{
				DeliveredOrderDAO deliveredOrderDAO = new DeliveredOrderDAO();
				return deliveredOrderDAO.GetDeliveredOrders(productCode, supplierCode, owner);
			}
			catch (BusinessException)
			{
				throw;
			}
			catch (Exception ex)
			{
				// log this exception
				Logger.Error(ex);
				// wrap it and rethrow
				throw new BusinessException(SR.BusinessGetDeliveredOrdersException, ex);
			}
		}   

		public static DeliveredOrderCollection GetDeliveredOrders(int bulkOrderID)
		{            
			try
			{
				DeliveredOrderDAO deliveredOrderDAO = new DeliveredOrderDAO();
				return deliveredOrderDAO.GetDeliveredOrders(bulkOrderID);
			}
			catch (BusinessException)
			{
				throw;
			}
			catch (Exception ex)
			{
				// log this exception
				Logger.Error(ex);
				// wrap it and rethrow
				throw new BusinessException(SR.BusinessGetDeliveredOrdersException, ex);
			}
		}   

    }
}